unit AvansEdit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DATAEDIT, StdCtrls, Mask, ToolEdit, CurrEdit;

type
  TfmAvansEdit = class(TfmDataEdit)
    cmbType: TComboBox;
    edtSum: TCurrencyEdit;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  protected
    procedure DisplayData; override;
    procedure DoBeforePost; override;
    procedure InitNewRec; override;
  public
    { Public declarations }
  end;

var
  fmAvansEdit: TfmAvansEdit;

implementation
uses DM;
{$R *.DFM}

procedure TfmAvansEdit.FormCreate(Sender: TObject);
var i: integer;
begin
  inherited;
  HandleStdKeys := True;
  DataSet := dmData.qAvans;
  for i := Low(OrderTypes) to High(OrderTypes) do
    cmbType.Items.Add(OrderTypes[i]);
end;

procedure TfmAvansEdit.DisplayData;
begin
  inherited;
  cmbType.ItemIndex := DataSet.FieldByName('pri').AsInteger - 1;
end;

procedure TfmAvansEdit.DoBeforePost;
begin
  inherited;
  DataSet.FieldByName('pri').AsInteger := cmbType.ItemIndex + 1;
  DataSet.FieldByName('dat').AsDateTime := OperDay;
end;

procedure TfmAvansEdit.InitNewRec;
begin
  inherited;
  cmbType.ItemIndex := 0;
end;

end.
